
import sys

irightNumber = 0
queensList = [None]*8

def printQueensList():
    global  irightNumber,queensList

def checkPosIsOk( InList, curDeep, curPos):
    for col in range(curDeep):
        if InList[col]==curPos:
            return False
        if (col + InList[col]) == (curDeep + curPos   ):
            return False
        if (col - InList[col]) == (curDeep - curPos   ):
            return False
    return True


def queenGetLmx( InList, curDeep=0):
    global  irightNumber,queensList
    for col in range(len(InList)):
        if True==checkPosIsOk(InList, curDeep, col):
            InList[curDeep] = col
            if( curDeep==( len(InList)-1) ):
                printQueensList()
                irightNumber = irightNumber+1
                InList[curDeep] = None;
                return
            queenGetLmx( InList, curDeep+1)
            InList[curDeep] = None;


def queen(A, cur=0):
    if cur == len(A):
        print(A)
        return 0
    for col in range(len(A)):
        A[cur], flag = col, True
        for row in range(cur):
            if A[row] == col or abs(col - A[row]) == cur - row:
                flag = False
                break
        if flag:
            queen(A, cur+1)
#queen([None]*8)
queenGetLmx( queensList)
#queen( queensList)



print( "hello world!")
print("irightNumber=%d" % (irightNumber) )
